package com.ghck.server.config.handler;

import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

//@ControllerAdvice
public class GhckExceptionHandler {
	
	private static Logger logger = org.slf4j.LoggerFactory.getLogger(GhckExceptionHandler.class);
	
	@ExceptionHandler
	public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
        ModelAndView mav = new ModelAndView();
        mav.addObject("exception", e);
        mav.addObject("url", req.getRequestURL());
        logger.info("url : {}",req.getRequestURL());
        String url = req.getHeader("REFERER");
        logger.info("url : {}",url);
        mav.setViewName("");
        return mav;
    }
	
}